package serializer

import "study_abroad_system_back_end/models"

type MajorInfo struct {
	ID          int		`gorm:"json:"id,omitempty"`
	Name      	string	`gorm:"json:"name,omitempty"`
	Rank		int		`gorm:"json:"rank,omitempty"`
	Content  	string  `gorm:"json:"content,omitempty"`
	Types 		string	`gorm:"json:"types,omitempty"`
}

func BuildMajorInfo(major models.Major) MajorInfo {
	return MajorInfo{
		ID: major.ID,
		Name: major.Name,
		Rank: major.Rank,
		Content: major.Content,
		Types: major.Types,
	}
}

func BuildMajorList(items []models.Major) (majors []MajorInfo){
	for _, item := range items {
		major := BuildMajorInfo(item)
		majors = append(majors, major)
	}
	return majors
}
